package com.jt.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Administrator on 2017/3/30.
 */
@Service
public class HystrixGreetService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "fallback")
    public String greet() {
        return restTemplate.getForObject("http://SPRING.CLOUD/greet", String.class);
    }

    @HystrixCommand(fallbackMethod = "fallback")
    public String add(String name) {
        return restTemplate.getForObject("http://SPRING.CLOUD/add?" + name, String.class);
    }

    public String fallback() {
        return "error";
    }

    public String fallback(String name) {
        return "error";
    }

}
